package com.google.code.easyparking.vue;
import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.ComboBoxModel;
import javax.swing.DefaultComboBoxModel;

import javax.swing.GroupLayout;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JComponent;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JSeparator;
import javax.swing.JSplitPane;
import javax.swing.JTextField;
import javax.swing.JToggleButton;
import javax.swing.LayoutStyle;

import com.google.code.easyparking.controleur.ControleurParking;
import com.google.code.easyparking.controleur.IControleurParking;
import com.google.code.easyparking.metier.FullParkingException;
import com.google.code.easyparking.metier.VehiculeAlreadyInParkingException;




/**
* This code was edited or generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details.
* Use of Jigloo implies acceptance of these licensing terms.
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*/
public class Administration extends JFrame {
	
	private JPanel jPanel1;
	
	private JMenuItem nouvParking;
	
	private JSeparator jSeparator2;
	
	private JMenuItem ouvrir;
	
	private JSeparator jSeparator1;
	
	private JMenu jMenu1;
	
	private JMenuBar fichier;

	private JMenuItem quitter;
	private JLabel labelParking;
	private JTextField texteNom;
	private JTextField texteNbPlaces;
	private JLabel labelNbPlacesLibres;
	private JSeparator jSeparator4;
	private JButton boutonSimuCam;
	private JSeparator jSeparator3;
	private JTextField texteNbEntrees;
	private JLabel labelNbEntrees;

	private JButton boutonValider;
	
	private JTextField jTextField1;
	
	private JLabel jLabel1;
	
	private JPanel jPanel3;
	
	private JPanel jPanel2;
	
	private JSplitPane jSplitPane1;
	
	private IControleurParking controleurParking ;
	
	public void initGUI() {
		try {
			{
				this.setTitle("EasyParking");
			}
			{
				fichier = new JMenuBar();
				setJMenuBar(fichier);
				{
					jMenu1 = new JMenu();
					fichier.add(jMenu1);
					jMenu1.setText("Fichier");
					{
						nouvParking = new JMenuItem();
						jMenu1.add(nouvParking);
						nouvParking.setText("Nouveau parking ...");
					}
					{
						jSeparator1 = new JSeparator();
						jMenu1.add(jSeparator1);
					}
					{
						ouvrir = new JMenuItem();
						jMenu1.add(ouvrir);
						ouvrir.setText("Ouvrir");
					}
					{
						jSeparator2 = new JSeparator();
						jMenu1.add(jSeparator2);
					}
					{
						quitter = new JMenuItem();
						jMenu1.add(quitter);
						quitter.setText("Quitter");
						quitter.addActionListener(new ActionListener(){
							public void actionPerformed(ActionEvent event){
								System.exit(0);
								}
						});
					}
				}
			}
			{
				jPanel1 = new JPanel();
				GroupLayout jPanel1Layout = new GroupLayout((JComponent)jPanel1);
				jPanel1.setLayout(jPanel1Layout);
				getContentPane().add(jPanel1, BorderLayout.CENTER);
				jPanel1.setPreferredSize(new java.awt.Dimension(530, 240));
				{
					jSplitPane1 = new JSplitPane();
					jSplitPane1.setOrientation(JSplitPane.VERTICAL_SPLIT);
					{
						jPanel3 = new JPanel();
						GroupLayout jPanel3Layout = new GroupLayout(jPanel3);
						jSplitPane1.add(jPanel3, JSplitPane.BOTTOM);
						jPanel3.setLayout(jPanel3Layout);
						jPanel3.setPreferredSize(new java.awt.Dimension(498, 40));
						jPanel3Layout.setVerticalGroup(jPanel3Layout.createParallelGroup());
						jPanel3Layout.setHorizontalGroup(jPanel3Layout.createParallelGroup());
					}
				}
				{
					jPanel2 = new JPanel();
					GroupLayout jPanel2Layout = new GroupLayout((JComponent)jPanel2);
					jPanel2.setLayout(jPanel2Layout);
					{
						jLabel1 = new JLabel();
						jLabel1.setText("Capacité");
					}
					{
						jTextField1 = new JTextField();
					}
					{
						boutonValider = new JButton();
						boutonValider.setText("Créer Parking");
						boutonValider.addActionListener(new ActionListener(){
							public void actionPerformed(ActionEvent event){
								controleurParking = new ControleurParking(
										texteNbEntrees.getText(), 
										Integer.parseInt(jTextField1.getText()), 
										Integer.parseInt(texteNbEntrees.getText()));
							}
						});
					}
					{
						labelParking = new JLabel();
						labelParking.setText("Nom du parking");
					}
					{
						texteNom = new JTextField();
					}
					{
						labelNbEntrees = new JLabel();
						labelNbEntrees.setText("Nombre d' accès");
					}
					{
						jSeparator3 = new JSeparator();
					}
					{
						texteNbPlaces = new JTextField();
						texteNbPlaces.setEditable(false);
					}
					{
						jSeparator4 = new JSeparator();
					}
					{
						labelNbPlacesLibres = new JLabel();
						labelNbPlacesLibres.setText("Nb places libres");
					}
					{
						boutonSimuCam = new JButton();
						boutonSimuCam.setText("Simuler l'entrée du véhicule");
						boutonSimuCam.setBackground(new java.awt.Color(255,165,0));
						
						boutonSimuCam.addActionListener(new ActionListener(){
							public void actionPerformed(ActionEvent event){
								
								try {
									int placeAttribue = controleurParking.getParking().getAccesParking(0).getCamera().vehiculeArrive();
									JOptionPane.showConfirmDialog(null, "La place " + placeAttribue + " vous a ete attribué", "", 0);
									updateNbPlaces();
								} catch (FullParkingException e) {
									// TODO Auto-generated catch block
									e.printStackTrace();
								} catch (VehiculeAlreadyInParkingException e) {
									// TODO Auto-generated catch block
									e.printStackTrace();
								}
								
							}


						});
					}
					{
						texteNbEntrees = new JTextField();
					}
					jPanel2Layout.setHorizontalGroup(jPanel2Layout.createSequentialGroup()
						.addContainerGap()
						.addGroup(jPanel2Layout.createParallelGroup()
						    .addGroup(GroupLayout.Alignment.LEADING, jPanel2Layout.createSequentialGroup()
						        .addGroup(jPanel2Layout.createParallelGroup()
						            .addComponent(labelNbPlacesLibres, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 142, GroupLayout.PREFERRED_SIZE)
						            .addGroup(GroupLayout.Alignment.LEADING, jPanel2Layout.createSequentialGroup()
						                .addComponent(jLabel1, GroupLayout.PREFERRED_SIZE, 102, GroupLayout.PREFERRED_SIZE)
						                .addGap(40))
						            .addComponent(labelParking, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 142, GroupLayout.PREFERRED_SIZE)
						            .addComponent(labelNbEntrees, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 142, GroupLayout.PREFERRED_SIZE))
						        .addGroup(jPanel2Layout.createParallelGroup()
						            .addGroup(GroupLayout.Alignment.LEADING, jPanel2Layout.createSequentialGroup()
						                .addComponent(texteNbEntrees, GroupLayout.PREFERRED_SIZE, 202, GroupLayout.PREFERRED_SIZE)
						                .addGap(24))
						            .addGroup(GroupLayout.Alignment.LEADING, jPanel2Layout.createSequentialGroup()
						                .addComponent(jTextField1, GroupLayout.PREFERRED_SIZE, 47, GroupLayout.PREFERRED_SIZE)
						                .addGap(179))
						            .addGroup(GroupLayout.Alignment.LEADING, jPanel2Layout.createSequentialGroup()
						                .addComponent(texteNom, GroupLayout.PREFERRED_SIZE, 214, GroupLayout.PREFERRED_SIZE)
						                .addGap(12))
						            .addGroup(jPanel2Layout.createSequentialGroup()
						                .addPreferredGap(texteNbEntrees, texteNbPlaces, LayoutStyle.ComponentPlacement.INDENT)
						                .addGroup(jPanel2Layout.createParallelGroup()
						                    .addGroup(GroupLayout.Alignment.LEADING, jPanel2Layout.createSequentialGroup()
						                        .addComponent(texteNbPlaces, GroupLayout.PREFERRED_SIZE, 143, GroupLayout.PREFERRED_SIZE)
						                        .addGap(71))
						                    .addGroup(GroupLayout.Alignment.LEADING, jPanel2Layout.createSequentialGroup()
						                        .addGap(7)
						                        .addComponent(boutonSimuCam, GroupLayout.PREFERRED_SIZE, 207, GroupLayout.PREFERRED_SIZE)))))
						        .addGap(24)
						        .addComponent(boutonValider, GroupLayout.PREFERRED_SIZE, 166, GroupLayout.PREFERRED_SIZE)
						        .addGap(0, 159, Short.MAX_VALUE))
						    .addGroup(GroupLayout.Alignment.LEADING, jPanel2Layout.createSequentialGroup()
						        .addComponent(jSeparator4, 0, 711, Short.MAX_VALUE)
						        .addGap(6))
						    .addComponent(jSeparator3, GroupLayout.Alignment.LEADING, 0, 717, Short.MAX_VALUE))
						.addGap(6));
					jPanel2Layout.setVerticalGroup(jPanel2Layout.createSequentialGroup()
						.addGroup(jPanel2Layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
						    .addComponent(jLabel1, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, 29, GroupLayout.PREFERRED_SIZE)
						    .addComponent(jTextField1, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, 24, GroupLayout.PREFERRED_SIZE))
						.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
						.addGroup(jPanel2Layout.createParallelGroup()
						    .addComponent(boutonValider, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 48, GroupLayout.PREFERRED_SIZE)
						    .addGroup(jPanel2Layout.createSequentialGroup()
						        .addGroup(jPanel2Layout.createParallelGroup()
						            .addComponent(texteNom, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
						            .addGroup(GroupLayout.Alignment.LEADING, jPanel2Layout.createSequentialGroup()
						                .addComponent(labelParking, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
						                .addGap(7)))
						        .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
						        .addGroup(jPanel2Layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
						            .addComponent(texteNbEntrees, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
						            .addComponent(labelNbEntrees, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE))))
						.addGap(16)
						.addComponent(jSeparator3, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
						.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, 0, Short.MAX_VALUE)
						.addComponent(boutonSimuCam, GroupLayout.PREFERRED_SIZE, 35, GroupLayout.PREFERRED_SIZE)
						.addComponent(jSeparator4, GroupLayout.PREFERRED_SIZE, 8, GroupLayout.PREFERRED_SIZE)
						.addGap(25)
						.addGroup(jPanel2Layout.createParallelGroup()
						    .addComponent(texteNbPlaces, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
						    .addGroup(GroupLayout.Alignment.LEADING, jPanel2Layout.createSequentialGroup()
						        .addGap(0, 7, GroupLayout.PREFERRED_SIZE)
						        .addComponent(labelNbPlacesLibres, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE))));
				}
				jPanel1Layout.setVerticalGroup(jPanel1Layout.createSequentialGroup()
					.addComponent(jPanel2, GroupLayout.PREFERRED_SIZE, 196, GroupLayout.PREFERRED_SIZE)
					.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
					.addComponent(jSplitPane1, GroupLayout.PREFERRED_SIZE, 142, GroupLayout.PREFERRED_SIZE));
				jPanel1Layout.setHorizontalGroup(jPanel1Layout.createSequentialGroup()
					.addContainerGap()
					.addGroup(jPanel1Layout.createParallelGroup()
					    .addComponent(jSplitPane1, GroupLayout.Alignment.LEADING, 0, 740, Short.MAX_VALUE)
					    .addGroup(GroupLayout.Alignment.LEADING, jPanel1Layout.createSequentialGroup()
					        .addComponent(jPanel2, GroupLayout.PREFERRED_SIZE, 735, GroupLayout.PREFERRED_SIZE)
					        .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, 0, Short.MAX_VALUE))));
			}
			pack();
			this.setSize(794, 287);
		} catch(Exception e) {
			e.printStackTrace();
		}
	}


	
	private void updateNbPlaces() {
		texteNbPlaces.setText(Integer.toString(controleurParking.getNbPLacesLibres()));
	}

	public JTextField getjTextField1() {
		return jTextField1;
	}
}
